主题
获取OLA图像 - GetOlaImage
函数简介
从OLA数据库中获取指定目录和文件名的图像数据,返回图像对象的指针。
接口名称
GetOlaImageDLL调用
cpp
long GetOlaImage(long ola, const long db, string dir, string fileName);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整型数 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成 |
| db | 长整型数 | 数据库连接句柄,由 OpenDatabase 接口生成 |
| dir | 字符串 | 图片目录路径 |
| fileName | 字符串 | 图片文件名 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.GetOlaImage(0, "value", "C:\\test.txt");csharp
using OLAPlug;
var ola = new OLAPlugServer();
long handle = ola.GetOlaImage(0, "value", "C:\\test.txt");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
handle = ola.GetOlaImage(0, "value", "C:\\test.txt")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long handle = ola.GetOlaImage(0, "value", "C:\\test.txt");cpp
var ola = com("OlaPlug.OlaSoft")
var handle = ola.GetOlaImage(0, "value", "C:\\test.txt")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
handle = ola.GetOlaImage(0, "value", "C:\\test.txt")text
.局部变量 ola, OLAPlug
ola.创建 ()
handle = ola.GetOlaImage(0, "value", "C:\\test.txt")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var handle = ola.GetOlaImage(0, "value", "C:\\test.txt");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 handle = ola.GetOlaImage(0, "value", "C:\\test.txt")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.GetOlaImage(0, "value", "C:\\test.txt");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long ptr = GetOlaImage(instance, 0, "value", "C:\\test.txt");
if (ptr != 0) {
char buffer[512] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetOlaImage(long ola, long db, string dir, string fileName);
long instance = CreateCOLAPlugInterFace();
long ptr = GetOlaImage(instance, 0, "value", "C:\\test.txt");
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string result = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ptr = ola.GetOlaImage(instance, 0, "value", "C:\\test.txt")
if ptr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(ptr, buf, 512)
ola.FreeStringPtr(ptr)
result = buf.value.decode("utf-8")返回值
图像对象的指针。如果操作失败,返回 0。
注意事项
- 适用于从数据库中检索单个图像的场景。
- 如果图像不存在或操作失败,可通过 GetDatabaseError 获取详细错误信息。
- 使用完返回的图像对象指针后,应妥善处理资源,避免内存泄漏。
